Traditional electronic device having a camera needs to turn on the flash lamp when the electronic device takes photographs in dark environment. However, when the object moves, light supplementing effect of the object is influenced because the flash lamp cannot track the object automatically.